home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Graphics / Ghostscript / source / gxpcolor.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  5.3 KB  |  126 lines

  1. /* Copyright (C) 1993, 1995, 1996, 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gxpcolor.h */
  20. /* Internal definitions for Pattern colors */
  21. /* Requires gsmatrix.h, gxdevice.h, gxdevmem.h, gxcolor2.h, gxdcolor.h */
  22. #include "gxpcache.h"
  23.  
  24. /*
  25.  * Define the Pattern device color types.  There is one type for
  26.  * colored patterns, and one uncolored pattern type for each non-Pattern
  27.  * device color type.
  28.  */
  29. extern const gx_device_color_procs
  30.     gx_dc_pattern, gx_dc_pure_masked,
  31.     gx_dc_binary_masked, gx_dc_colored_masked;
  32. #define gx_dc_type_pattern (&gx_dc_pattern)
  33.  
  34. /*
  35.  * Define a color tile, an entry in the rendered Pattern cache (and
  36.  * eventually in the colored halftone cache).  Note that the depth is
  37.  * not sufficient to ensure that the rendering matches a given device;
  38.  * however, we don't currently have an object that represents the
  39.  * abstraction of a 'color representation'.
  40.  */
  41. struct gx_color_tile_s {
  42.         /* ------ The following are the 'key' in the cache. ------ */
  43.         /* Note that the id is a generated instance ID, */
  44.         /* and has no relation to the template's gs_uid. */
  45.     gx_bitmap_id id;
  46.     int depth;
  47.         /* We do, however, copy the template's gs_uid, */
  48.         /* for use in selective cache purging. */
  49.     gs_uid uid;
  50.         /* ------ The following are the cache 'value'. ------ */
  51.         /* Note that if tbits and tmask both have data != 0, */
  52.         /* both must have the same rep_shift. */
  53.         /****** NON-ZERO shift VALUES ARE NOT SUPPORTED YET. ******/
  54.     int tiling_type;        /* TilingType */
  55.     gs_matrix step_matrix;        /* tiling space -> device space, */
  56.                     /* see gxcolor2.h for details */
  57.     gs_rect bbox;            /* bbox of tile in tiling space */
  58.     gx_strip_bitmap tbits;        /* data = 0 if uncolored */
  59.     gx_strip_bitmap tmask;        /* data = 0 if no mask */
  60.                     /* (i.e., the mask is all 1's) */
  61.     bool is_simple;            /* true if xstep/ystep = tile size */
  62.         /* The following is neither key nor value. */
  63.     uint index;            /* the index of the tile within */
  64.                     /* the cache (for GC) */
  65. };
  66. #define private_st_color_tile()    /* in gxpcmap.c */\
  67.   gs_private_st_ptrs2(st_color_tile, gx_color_tile, "gx_color_tile",\
  68.     color_tile_enum_ptrs, color_tile_reloc_ptrs, tbits.data, tmask.data)
  69. #define private_st_color_tile_element()    /* in gxpcmap.c */\
  70.   gs_private_st_element(st_color_tile_element, gx_color_tile,\
  71.     "gx_color_tile[]", color_tile_elt_enum_ptrs, color_tile_elt_reloc_ptrs,\
  72.     st_color_tile)
  73.  
  74. /* Define the Pattern cache. */
  75. /*#include "gxpcache.h"*/    /* (above) */
  76.  
  77. /* Allocate a Pattern cache. */
  78. /* We shorten the procedure names because some VMS compilers */
  79. /* truncate names to 23 characters. */
  80. uint gx_pat_cache_default_tiles(P0());
  81. ulong gx_pat_cache_default_bits(P0());
  82. gx_pattern_cache *gx_pattern_alloc_cache(P3(gs_memory_t *, uint, ulong));
  83.  
  84. /* Get or set the Pattern cache in a gstate. */
  85. gx_pattern_cache *gstate_pattern_cache(P1(gs_state *));
  86. void gstate_set_pattern_cache(P2(gs_state *, gx_pattern_cache *));
  87.  
  88. /*
  89.  * Define a device for accumulating the rendering of a Pattern.
  90.  * This is actually a wrapper for two other devices: one that accumulates
  91.  * the actual pattern image (if this is a colored pattern), and one that
  92.  * accumulates a mask defining which pixels in the image are set.
  93.  */
  94. typedef struct gx_device_pattern_accum_s {
  95.     gx_device_forward_common;
  96.         /* Client sets these before opening */
  97.     gs_memory_t *bitmap_memory;
  98.     const gs_pattern_instance *instance;
  99.         /* open sets these */
  100.     gx_device_memory *bits;        /* target also points to bits */
  101.     gx_device_memory *mask;
  102. } gx_device_pattern_accum;
  103. #define private_st_device_pattern_accum() /* in gxpcmap.c */\
  104.   gs_private_st_suffix_add3(st_device_pattern_accum, gx_device_pattern_accum,\
  105.     "pattern accumulator", pattern_accum_enum, pattern_accum_reloc,\
  106.     st_device_forward, instance, bits, mask)
  107.  
  108. /* Allocate a pattern accumulator. */
  109. gx_device_pattern_accum *gx_pattern_accum_alloc(P2(gs_memory_t *memory, client_name_t));
  110.  
  111. /* Add an accumulated pattern to the cache. */
  112. /* Note that this does not free any of the data in the accumulator */
  113. /* device, but it may zero out the bitmap_memory pointers to prevent */
  114. /* the accumulated bitmaps from being freed when the device is closed. */
  115. int gx_pattern_cache_add_entry(P3(gs_imager_state *, gx_device_pattern_accum *,
  116.                   gx_color_tile **));
  117.  
  118. /* Look up a pattern color in the cache. */
  119. bool gx_pattern_cache_lookup(P4(gx_device_color *, const gs_imager_state *,
  120.                 gx_device *, gs_color_select_t));
  121.  
  122. /* Purge selected entries from the pattern cache. */
  123. void gx_pattern_cache_winnow(P3(gx_pattern_cache *,
  124.                 bool (*)(P2(gx_color_tile *, void *)),
  125.                 void *));
  126.